# Python 2.6.4
# Project Euler, Problem 91
# Copyright 2010 Talha Zaman

def right(x1, y1, x2, y2):
    a = x1*x2 + y1*y2
    b = x1*(x2-x1) + y1*(y2-y1)
    c = x2*(x1-x2) + y2*(y1-y2)
    return a==0 or b==0 or c==0

dim, count = 50, 0
for x1 in range(1, dim+1):
    for y1 in range(dim+1):
        for x2 in range(x1+1):
            for y2 in range(max(y1, 1), dim+1):
                if x1==x2 and y1==y2: continue
                count += right(x1, y1, x2, y2)
print count
